Files

Files

Add a file to MDM for usage in other API.

Attribute

content_type
string
Content Type :
File Extension Platform Content type
apk Android application/vnd.android.package-archive
ipa iOS application/x-itunes-ipa
appxbundle Windows application/zip
xap Windows application/zip
appx Windows application/zip
msi Windows application/x-ms-installer
msix Windows application/zip
file_name
string
Name of File
file_id
long
Unique Identifier for the file
expiry_time
long
Timestamp until when the file is valid
content_length
integer
Length of the file (in bytes)

Example

{ "content_type": "image/png", "file_name": "check.png", "file_id": 123124, "expiry_time": 15987913528, "content_length": 1479 }

Upload a file to MDM

Upload a file
oauthscope : MDMOnDemand.MDMDeviceMgmt.CREATE

POST - /api/v1/mdm/files

Content-Disposition
string
(Required)
Name of file with extension

Arguments

stream
bytestream
(Required)
bytestream of the file

Request Example

Click to copy
import http.client conn = http.client.HTTPSConnection("www.mdm.manageengine.com") file_path = "path/to/your_file/file_name" file_name = "file_name" with open(file_path, "rb") as file: file_data = file.read() payload = file_data headers = { 'Authorization': "Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f", 'content-type': "application/json", 'content-disposition': f"filename={file_name}" } conn.request("POST", "/api/v1/mdm/files", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient(); File file = new File("path/to/your_file/file_name"); MediaType mediaType = MediaType.parse("application/json"); RequestBody body = RequestBody.create(mediaType, file); Request request = new Request.Builder() .url("https://www.mdm.manageengine.com/api/v1/mdm/files") .post(body) .addHeader("Authorization", "Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f") .addHeader("content-type", "application/json") .addHeader("content-disposition", "filename=file_name.extension") .build(); Response response = client.newCall(request).execute();
curl --request POST \ --url https://www.mdm.manageengine.com/api/v1/mdm/files \ --header 'Authorization: Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f' \ --header 'content-type: application/json' \ --header 'content-disposition: filename=fileName.extension' \ --data-binary '@location_to_your_file'

Response Example

HTTP/1.1 200 Create
{ "content_type": "image/png", "file_name": "check.png", "file_id": 123124, "expiry_time": 15987913528, "content_length": 1479 }

Upload a file to MDM with Module Configuration

File upload to server with module configuration. Upload image, audio, video, certificate and many more.
oauthscope : MDMOnDemand.MDMDeviceMgmt.CREATE

POST - /emsapi/files

Module
string
(Required)
Module configuration of which the file is going to be used.
eg. MDM_PROFILES_IMAGES for images in profiles creation and modification.
Few modules are listed here. you can find the module configurations in the respective APIs
  • MDM_PROFILES_IMAGES
  • MDM_APP_MGMT
  • MDM_CERTIFICATES
  • MDM_CUSTOM_PROFILE
  • MDM_CONTENT_MGMT
  • MDM_OS_UPDATE_POLICY

Request Body

string - bytestream
(Required)
In that Multipart-from request the key should be "file" and the value should be the file content(binary).

Request Example

Click to copy
import http.client import mimetypes import uuid import os conn = http.client.HTTPSConnection("www.mdm.manageengine.com") file_path = "path/to/your_file/file_name" file_name = os.path.basename(file_path) with open(file_path, "rb") as file: file_data = file.read() boundary = str(uuid.uuid4()) multipart_data = f"--{boundary}\r\n" f'Content-Disposition: form-data; name="fileName"; filename="{file_name}"\r\n' f"Content-Type: {mimetypes.guess_type(file_name)[0] or 'application/octet-stream'}\r\n" f"\r\n" ).encode("utf-8") + file_data + f"\r\n--{boundary}--\r\n".encode("utf-8") headers = { 'Authorization': "Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f", 'content-type': "application/json", 'module': "MDM_PROFILES_IMAGES" 'X-Customer': "1" } conn.request("POST", "/emsapi/files", payload, body=multipart_data, headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient(); File file = new File("path/to/your_file/file_name"); MediaType mediaType = MediaType.parse("application/json"); RequestBody fileBody = RequestBody.create(mediaType, file); RequestBody multipartBody = MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart("fileName", file.getName(), fileBody) .build(); Request request = new Request.Builder() .url("https://www.mdm.manageengine.com/api/v1/mdm/files") .post(multipartBody) .addHeader("Authorization", "Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f") .addHeader("content-type", "application/json") .addHeader("module", "MDM_PROFILES_IMAGES") .addHeader("X-Customer", "1") .build(); Response response = client.newCall(request).execute();
curl --request POST \ --url https://www.mdm.manageengine.com/api/v1/mdm/files \ --header 'Authorization: Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f' \ --header 'content-type: application/json' \ --header 'module: MDM_PROFILES_IMAGES' \ --header 'X-Customer: 1' \ --form 'fileName=@/path/to/your/file.ext'

Response Example

HTTP/1.1 200 Create
{ "fileID": "1", "fileName": "filename.ext", "customerID": "1", "expiryDate": "Jun 28, 2025 04:18 PM", "fileStatus": 2 }